package ink.lovejinhu.leetcode;

import java.util.HashMap;

/**
 * @author jinhu
 * created 2021-07-05 9:13
 */
public class Solution_0171 {
    /**
     * 秦九韶不熟悉
     * @param columnTitle
     * @return
     */
    public int titleToNumber(String columnTitle) {
        HashMap<Character, Integer> map = new HashMap<>();
        for (int i = 0; i < 26; i++) {
            map.put((char) ('A' + i), i + 1);

        }
        char[] chars = columnTitle.toCharArray();
        int res = 0;
        for (int i = 0; i < chars.length; i++) {
            Integer integer = map.get(chars[i]);
            res = res * 26 + integer;
        }

        return res;
    }

    public static void main(String[] args) {
        Solution_0171 solution_0171 = new Solution_0171();
        System.out.println(solution_0171.titleToNumber("ZY"));
    }
}
